<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 娜娜
  Date: 2024/12/26
  Time: 19:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>商品列表</title>
    <meta charset="utf-8"/>
    <link rel="stylesheet" href="css/bootstrap.css"/>
</head>
<body>
<div class="container-fluid">



<%--    <jsp:include page="/admin/header.jsp"></jsp:include>--%>


    <nav class="navbar navbar-default" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="">MilkTeaShop后台</a>
            </div>
            <div>
                <ul class="nav navbar-nav">
                    <li><a href="${pageContext.request.contextPath}/admin/order_list">订单管理</a></li>
                    <li><a href="${pageContext.request.contextPath}/admin/user_list">客户管理</a></li>
                    <li><a href="${pageContext.request.contextPath}/admin/goods_list">商品管理</a></li>
                    <li><a href="${pageContext.request.contextPath}/admin/type_list">类目管理</a></li>
                    <li><a href="${pageContext.request.contextPath}/logout">退出</a></li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="text-right"><a class="btn btn-warning" href="${pageContext.request.contextPath }/admin/goods_add.jsp">添加商品</a></div>

    <br>

    <ul role="tablist" class="nav nav-tabs">
        <li <c:if test="${type==0}">class="active"</c:if> role="presentation"><a href="${pageContext.request.contextPath }/admin/goods_list">全部商品</a></li>
        <li <c:if test="${type==1}">class="active"</c:if> role="presentation"><a href="${pageContext.request.contextPath }/admin/goods_list?type=1">条幅推荐</a></li>
        <li <c:if test="${type==2}">class="active"</c:if> role="presentation"><a href="${pageContext.request.contextPath }/admin/goods_list?type=2">热销推荐</a></li>
        <li <c:if test="${type==3}">class="active"</c:if> role="presentation"><a href="${pageContext.request.contextPath }/admin/goods_list?type=3">新品推荐</a></li>
    </ul>





    <br>

    <table class="table table-bordered table-hover">

        <tr>
            <th width="5%">ID</th>
            <th width="10%">图片</th>
            <th width="10%">名称</th>
            <th width="20%">介绍</th>
            <th width="10%">价格</th>
            <th width="10%">类目</th>
            <th width="25%">操作</th>
        </tr>

        <c:forEach items="${p.list }" var="g">
        <tr>
            <td><p>${g.id}</p></td>
            <td><p><a href="${pageContext.request.contextPath }/goods_detail?id=${g.id}" target="_blank"><img src="${pageContext.request.contextPath }${g.cover}" width="100px" height="100px"></a></p></td>
            <td><p><a href="${pageContext.request.contextPath }/goods_detail?id=${g.id}" target="_blank">${g.name}</a></p></td>
            <td>${g.intro}</td>
            <td>${g.price}</td>
            <td>${g.type.name}</td>
            <td>
                <p>

                    <c:choose>
                        <c:when test="${g.isScroll}">
                            <a class="btn btn-info" href="${pageContext.request.contextPath }/admin/goods_recommend?id=${g.id}&method=remove&typeTarge=1&pageNo=${p.pageNo}&type=${type}">移出条幅</a>
                        </c:when>
                        <c:otherwise>
                            <a class="btn btn-primary" href="${pageContext.request.contextPath }/admin/goods_recommend?id=${g.id}&method=add&typeTarge=1&pageNo=${p.pageNo}&type=${type}">加入条幅</a>
                        </c:otherwise>
                    </c:choose>

                    <c:choose>
                        <c:when test="${g.isHot}">
                            <a class="btn btn-info" href="${pageContext.request.contextPath }/admin/goods_recommend?id=${g.id}&method=remove&typeTarge=2&pageNo=${p.pageNo}&type=${type}">移出热销</a>
                        </c:when>
                        <c:otherwise>
                            <a class="btn btn-primary" href="${pageContext.request.contextPath }/admin/goods_recommend?id=${g.id}&method=add&typeTarge=2&pageNo=${p.pageNo}&type=${type}">加入热销</a>
                        </c:otherwise>
                    </c:choose>

                    <c:choose>
                        <c:when test="${g.isNew}">
                            <a class="btn btn-info" href="${pageContext.request.contextPath }/admin/goods_recommend?id=${g.id}&method=remove&typeTarge=3&pageNo=${p.pageNo}&type=${type}">移出新品</a>
                        </c:when>
                        <c:otherwise>
                            <a class="btn btn-primary" href="${pageContext.request.contextPath }/admin/goods_recommend?id=${g.id}&method=add&typeTarge=3&pageNo=${p.pageNo}&type=${type}">加入新品</a>
                        </c:otherwise>
                    </c:choose>








                </p>
                <a class="btn btn-success" href="${pageContext.request.contextPath }/admin/goods_editshow?id=${g.id}&pageNo=${p.pageNo}&type=${type}">修改</a>
                <a class="btn btn-danger" href="${pageContext.request.contextPath }/admin/goods_delete?id=${g.id}&pageNo=${p.pageNo}&type=${type}">删除</a>
            </td>
        </tr>
        </c:forEach>



    </table>

    <br>
    <div style='text-align:center;'>
        <a class='btn btn-info' <c:if test="${p.pageNo==1}">disabled</c:if> <c:if test="${p.pageNo!=1}">href="${pageContext.request.contextPath}/admin/goods_list?pageNo=1&type=${type}"</c:if>>首页</a>
        <a class='btn btn-info' <c:if test="${p.pageNo==1}">disabled</c:if> <c:if test="${p.pageNo!=1}">href="${pageContext.request.contextPath}/admin/goods_list?pageNo=${p.pageNo-1}&type=${type}"</c:if>>上一页</a>
        <h3 style='display:inline;'>[${p.pageNo}/${p.totalPage}]</h3>
<%--        <h3 style='display:inline;'>[${p.totalCount}]</h3>--%>
        <a class='btn btn-info' <c:if test="${p.totalPage==0 || p.pageNo==p.totalPage}">disabled</c:if> <c:if test="${p.pageNo!=p.totalPage}">href="${pageContext.request.contextPath}/admin/goods_list?pageNo=${p.pageNo+1}&type=${type}"</c:if>>下一页</a>
        <a class='btn btn-info' <c:if test="${p.totalPage==0 || p.pageNo==p.totalPage}">disabled</c:if> <c:if test="${p.pageNo!=p.totalPage}">href="${pageContext.request.contextPath}/admin/goods_list?pageNo=${p.totalPage}&type=${type}"</c:if>>尾页</a>
        <input type='text' class='form-control' style='display:inline;width:60px;' value=''/><a class='btn btn-info' href='javascript:void(0);' onclick='location.href="${pageContext.request.contextPath}/admin/goods_list?type=${type}&pageNo="+(this.previousSibling.value)'>GO</a>
    </div>
    <br>
</div>
</body>
</html>
